<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增游戏</title>
    <link rel="stylesheet" href="__ACSS__/table.css">
    <script src="__AJS__/jquery-3.3.1.min.js"></script>
</head>
<body>
    <div class="table-wrap">
        <div class="table-main">
            <div class="ibox-title">
                <h3>新增游戏<small>&nbsp;&nbsp;下方填写数据均不能为空</small></h3>
            </div>
            <div class="ibox-content">  
                <form action="{:url('admin/game/save')}" class="form-main" method="post" enctype=multipart/form-data>

                    <div class="form-group">
                        <ul>
                            <li>
                                <span class="form-title">游戏分类</span>
                                <select name="cateid" class="form-select">
                                    {volist name="cate" id="v"}
                                    <option value="{$v.cid}">{$v.cateName}</option>
                                    {/volist}
                                </select>
                            </li>
                            <li>
                                <span class="form-title">游戏名</span>
                                <input class="form-text form-w50" type="text" name="gName">
                            </li>
                            <li>
                                <span class="form-title">游戏描述</span>
                                <input class="form-text form-w50" type="text" name="gDesc">
                            </li>
                            <li>
                                <span class="form-title">预览地址</span>
                                <input class="form-text form-w50" type="text" name="viewUrl">
                            </li>
                            <li>
                                <span class="form-title">是否开启</span>
                                <label class="form-radio">
                                    <input type="radio" name="gStatus" value="0" checked>开启
                                </label>
                                <label class="form-radio">
                                    <input type="radio" name="gStatus" value="1">关闭
                                </label>
                            </li>
                            <li>
                                <span class="form-title">是否最新</span>
                                <label class="form-radio">
                                    <input type="radio" name="isNew" value="0">最新
                                </label>
                                <label class="form-radio">
                                    <input type="radio" name="isNew" value="1" checked>非最新
                                </label>
                            </li>
                            <li>
                                <span class="form-title">是否推荐</span>
                                <label class="form-radio">
                                    <input type="radio" name="isRecom" value="0">推荐
                                </label>
                                <label class="form-radio">
                                    <input type="radio" name="isRecom" value="1" checked>不推荐
                                </label>
                               
                                
                            </li>
                            <li>
                                <span class="form-title">游戏图片</span>
                                <div class="form-img" title="点击修改图片">
                                    <input type="file" id="fileuploadgame" class="fileupload-input" name="gImg">
                                    <div class="form-img-box">
                                        <div class="form-pre-item">
                                            <img src="">
                                        </div>
                                        <em class="edit_img_icon">&nbsp;</em>
                                    </div>
                                </div>
                            </li>
                            
                            <li>
                                <span class="form-title"></span>
                                <input class="form-submit-btn" type="submit" value="提交">
                                <a href="{:url('admin/game/index')}" class="form-back-btn"  name="">返回</a>
                            </li>
                        </ul>
                    </div>

                </form>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function(){
            // 本地化预览图片
            $('.form-pre-item').hide();
            // 单个
            $('#fileuploadgame').change(function(){
                var objUrl = getObjectURL(this.files[0]) ;
                if ( objUrl ) {
                    $(this).next('div').find('.form-pre-item').children('img').attr('src',objUrl);
                    $('.form-pre-item').show();
                }
            });
            
        });
        // 本地化预览图片 //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null ;
            if (window.createObjectURL!=undefined) { // basic
                url = window.createObjectURL(file) ;
            }else if (window.URL!=undefined) {
            // mozilla(firefox)
                url = window.URL.createObjectURL(file) ;
            } else if (window.webkitURL!=undefined) {
            // webkit or chrome
                url = window.webkitURL.createObjectURL(file) ;
            }
            return url ;
        }
    </script>
</body>
</html>